home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 August: Tool Chest / Apple_Developer_Group_August_1996_Tool_Chest.iso / Sample Code / Snippets / QuickDraw / PictInfoTest / Commands.c next >
Encoding:
Text File  |  1994-10-28  |  2.3 KB  |  92 lines  |  [TEXT/KAHL]

  1. // Simple framework for Macintosh sample code
  2. //
  3. // Nick Thompson, DEVSUPPORT
  4. //
  5. // Application handlers, called by the AE stuff.  
  6. // 
  7. // 9/16/94    nick    first cut
  8. //
  9. //    Copyright:    © 1989-94 by Apple Computer, Inc., all rights reserved.
  10.  
  11. #include "AppGlobals.h"
  12. #include "ErrorHandling.h"
  13. #include "ShellCommands.h"
  14.  
  15. //----------------------------------------------------------------------------------//
  16. //    Send a Quit Application Apple Event to myself to terminate this app.        
  17.  
  18. void SendQuitApp( void )
  19. {
  20.     AppleEvent    myAppleEvent, reply;
  21.     
  22.     //    Create the Apple Event.
  23.     FailIfErr(AECreateAppleEvent( kCoreEventClass, 
  24.                                   kAEQuitApplication, 
  25.                                   &gSelfAddress,
  26.                                   kAutoGenerateReturnID, 
  27.                                   kAnyTransactionID, 
  28.                                   &myAppleEvent));
  29.                                   
  30.     //    Send the Apple Event.
  31.       FailIfErr(AESend( &myAppleEvent, 
  32.                         &reply, 
  33.                         kAENoReply+kAENeverInteract, 
  34.                         kAENormalPriority,
  35.                         kAEDefaultTimeout, 
  36.                         nil, 
  37.                         nil));
  38.                         
  39.       AEDisposeDesc(&myAppleEvent);                // Dispose of the Apple Event.
  40. } // SendQuitApp
  41.  
  42. //----------------------------------------------------------------------------------//
  43. //    Send a Open Document Application Apple Event to myself to open a document.        
  44.  
  45. void SendOpenDoc(FSSpec *myFSSpec)
  46. {
  47.      AppleEvent    myAppleEvent;
  48.     AppleEvent    defReply;
  49.     AEDescList    docList;
  50.     OSErr         myErr;
  51.     OSErr         ignoreErr;
  52.     
  53.     myAppleEvent.dataHandle = nil;
  54.     docList.dataHandle  = nil;
  55.     defReply.dataHandle = nil;
  56.         
  57.     // Create empty list and add one file spec
  58.     FailIfErr(AECreateList(nil,0,false, &docList));
  59.     
  60.     FailIfErr(AEPutPtr(&docList,1,typeFSS,(Ptr)myFSSpec,sizeof(FSSpec)));
  61.         
  62.     FailIfErr(AECreateAppleEvent(    kCoreEventClass,
  63.                                     kAEOpenDocuments,
  64.                                     &gSelfAddress,
  65.                                     kAutoGenerateReturnID,
  66.                                     kAnyTransactionID,
  67.                                     &myAppleEvent));
  68.  
  69.     // Put Params into our event and send it
  70.  
  71.     FailIfErr(AEPutParamDesc( &myAppleEvent,
  72.                               keyDirectObject,
  73.                               &docList));
  74.  
  75.     FailIfErr(AESend( &myAppleEvent,
  76.                       &defReply,
  77.                       kAENoReply+kAENeverInteract,
  78.                       kAENormalPriority,
  79.                       kAEDefaultTimeout,
  80.                       nil,
  81.                       nil));
  82.         
  83.         
  84.     if (myAppleEvent.dataHandle) 
  85.         ignoreErr = AEDisposeDesc(&myAppleEvent);
  86.         
  87.     if (docList.dataHandle) 
  88.         ignoreErr = AEDisposeDesc(&docList);
  89.             
  90. }    // SendOpenDoc 
  91.  
  92.